From e762a58a6833ee88d210bc37aa873992aa2346b6 Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 30 Apr 2006 04:07:55 +0000 Subject: [PATCH] Implement progress bars for track read. --- jeeps/gps.h | 2 +- jeeps/gpsapp.c | 7 +++++-- jeeps/gpsapp.h | 4 ++-- jeeps/gpscom.c | 8 ++++---- jeeps/gpscom.h | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/jeeps/gps.h b/jeeps/gps.h index 93ca4bf91..35062287b 100644 --- a/jeeps/gps.h +++ b/jeeps/gps.h @@ -179,7 +179,7 @@ typedef struct GPS_SLap_Data { UC track_index; } GPS_OLap_Data, *GPS_PLap_Data; - +typedef int (*pcb_fn) (int, struct GPS_SWay **); #include "gpsdevice.h" #include "gpssend.h" diff --git a/jeeps/gpsapp.c b/jeeps/gpsapp.c index 80b789a38..bf8ef5a99 100644 --- a/jeeps/gpsapp.c +++ b/jeeps/gpsapp.c @@ -3340,7 +3340,7 @@ static void GPS_D210_Send(UC *data, GPS_PWay way, int32 *len) ** ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_A300_Get(const char *port, GPS_PTrack **trk) +int32 GPS_A300_Get(const char *port, GPS_PTrack **trk, pcb_fn cb) { static UC data[2]; gpsdevh *fd; @@ -3469,7 +3469,7 @@ drain_run_cmd(gpsdevh *fd) ** ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_A301_Get(const char *port, GPS_PTrack **trk) +int32 GPS_A301_Get(const char *port, GPS_PTrack **trk, pcb_fn cb) { static UC data[2]; gpsdevh *fd; @@ -3477,6 +3477,7 @@ int32 GPS_A301_Get(const char *port, GPS_PTrack **trk) GPS_PPacket rec; int32 n; int32 i; + int ntrkpts; if(gps_trk_transfer == -1) return GPS_UNSUPPORTED; @@ -3576,6 +3577,8 @@ int32 GPS_A301_Get(const char *port, GPS_PTrack **trk) GPS_Error("A301_GET: Unknown track protocol"); return PROTOCOL_ERROR; } + /* Cheat and don't _really_ pass the trkpt back */ + cb(n, NULL); } if(!GPS_Packet_Read(fd, &rec)) diff --git a/jeeps/gpsapp.h b/jeeps/gpsapp.h index e12208e4b..2d9ead9c1 100644 --- a/jeeps/gpsapp.h +++ b/jeeps/gpsapp.h @@ -20,8 +20,8 @@ int32 GPS_A201_Get(const char *port, GPS_PWay **way); int32 GPS_A200_Send(const char *port, GPS_PWay *way, int32 n); int32 GPS_A201_Send(const char *port, GPS_PWay *way, int32 n); -int32 GPS_A300_Get(const char *port, GPS_PTrack **trk); -int32 GPS_A301_Get(const char *port, GPS_PTrack **trk); +int32 GPS_A300_Get(const char *port, GPS_PTrack **trk, pcb_fn cb); +int32 GPS_A301_Get(const char *port, GPS_PTrack **trk, pcb_fn cb); int32 GPS_A300_Send(const char *port, GPS_PTrack *trk, int32 n); int32 GPS_A301_Send(const char *port, GPS_PTrack *trk, int32 n); diff --git a/jeeps/gpscom.c b/jeeps/gpscom.c index e8a2874e1..e2fe2afd6 100644 --- a/jeeps/gpscom.c +++ b/jeeps/gpscom.c @@ -83,7 +83,7 @@ int32 GPS_Command_Off(const char *port) ** @return [int32] number of waypoint entries ************************************************************************/ -int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way, int (*cb)(int, struct GPS_SWay **)) +int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way, pcb_fn cb) { int32 ret=0; @@ -219,7 +219,7 @@ int32 GPS_Command_Send_Route(const char *port, GPS_PWay *way, int32 n) ** @return [int32] number of track entries ************************************************************************/ -int32 GPS_Command_Get_Track(const char *port, GPS_PTrack **trk) +int32 GPS_Command_Get_Track(const char *port, GPS_PTrack **trk, pcb_fn cb) { int32 ret=0; @@ -229,11 +229,11 @@ int32 GPS_Command_Get_Track(const char *port, GPS_PTrack **trk) switch(gps_trk_transfer) { case pA300: - ret = GPS_A300_Get(port,trk); + ret = GPS_A300_Get(port,trk,cb); break; case pA301: case pA302: - ret = GPS_A301_Get(port,trk); + ret = GPS_A301_Get(port,trk,cb); break; default: GPS_Error("Get_Track: Unknown track protocol %d\n", gps_trk_transfer); diff --git a/jeeps/gpscom.h b/jeeps/gpscom.h index 40f49c219..96e10f055 100644 --- a/jeeps/gpscom.h +++ b/jeeps/gpscom.h @@ -25,7 +25,7 @@ int32 GPS_Command_Pvt_Get(gpsdevh **fd, GPS_PPvt_Data *pvt); int32 GPS_Command_Get_Almanac(const char *port, GPS_PAlmanac **alm); int32 GPS_Command_Send_Almanac(const char *port, GPS_PAlmanac *alm, int32 n); -int32 GPS_Command_Get_Track(const char *port, GPS_PTrack **trk); +int32 GPS_Command_Get_Track(const char *port, GPS_PTrack **trk, int (*cb)(int, struct GPS_SWay **)); int32 GPS_Command_Send_Track(const char *port, GPS_PTrack *trk, int32 n); int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way,int (*cb)(int, struct GPS_SWay **)); -- 2.30.2